﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace RiskMan.DataClass.Models
{
    [Serializable]
    public class QuikItem : INotifyPropertyChanged, ISerializable
    {
        private String _Name;
        private String _Path;
        private bool _isConn;
        private ObservableCollection<Trade> _TradeList;
        private String _TypeAccount;
        private String _MarketPlace;
        private String _Comments;

        public String Name
        {
            get { return _Name; }
            set
            {
                if ( _Name != value )
                {
                    _Name = value;
                    RaisePropertyChanged( "Name" );
                }
            }
        }
        public String Path
        {
            get { return _Path; }
            set
            {
                if ( _Path != value )
                {
                    _Path = value;
                    RaisePropertyChanged( "Path" );
                }
            }
        }
        public bool IsConn
        {
            get { return _isConn; }
            set
            {
                if ( _isConn != value )
                {
                    _isConn = value;
                    RaisePropertyChanged( "IsConn");
                }
            }
        }

        public ObservableCollection<Trade> TradeList
        {
            get { return _TradeList; }
            set
            {
                if ( _TradeList != value )
                {
                    _TradeList = value;
                    RaisePropertyChanged( "TradeList" );
                }
            }
        }
        public String TypeAccount
        {
            get { return _TypeAccount; }
            set
            {
                if ( _TypeAccount != value )
                {
                    _TypeAccount = value;
                    RaisePropertyChanged( "TypeAccount" );
                }
            }
        }
        public String Comments
        {
            get { return _Comments; }
            set
            {
                if ( _Comments != value )
                {
                    _Comments = value;
                    RaisePropertyChanged( "Comments" );
                }
            }
        }
        public String MarketPlace
        {
            get { return _MarketPlace; }
            set
            {
                if ( _MarketPlace != value )
                {
                    _MarketPlace = value;
                    RaisePropertyChanged( "MarketPlace" );
                }
            }
        }

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged ( string propertyName )
        {
            var handler = PropertyChanged;
            if ( handler != null )
            {
                handler( this, new PropertyChangedEventArgs( propertyName ) );
            }
        }

        #endregion

        public QuikItem ( ) { }

        protected QuikItem ( SerializationInfo info, StreamingContext context )
        {
            Name = ( string ) info.GetValue( "Name", typeof( string ) );
            Path = ( string ) info.GetValue( "Path", typeof( string ) );
            Comments = ( string ) info.GetValue( "Comments", typeof( string ) );
            TradeList = ( ObservableCollection<Trade> ) info.GetValue( "TradeList", typeof( ObservableCollection<Trade> ) );
        }

        public void GetObjectData ( SerializationInfo info, StreamingContext context )
        {
            info.AddValue( "Name", _Name );
            info.AddValue( "Path", _Path );
            info.AddValue( "Comments", _Comments );
            info.AddValue( "TradeList", _TradeList );
        }
    }
}
